#include <stdio.h>
#include <stdlib.h>

enum{ len = 12 };

void func(void){
    char id[len];
    int r;
    int num;
    /* ... */
    r=rand();
    num = snprintf(id,len,"ID %d",r);
    /* ... */
}